package cc.rengu.igas.momp.common.dao.impl;

import cc.rengu.igas.momp.common.constant.CommonConstant;
import cc.rengu.igas.momp.common.dao.McDetailInfoMapper;
import cc.rengu.igas.momp.common.entity.*;
import cc.rengu.igas.momp.common.enums.McStatusEnum;
import cc.rengu.igas.momp.common.enums.TableNameEnum;
import cc.rengu.jradp.mods.dbs.Database;
import cc.rengu.oltp.service.common.constant.AppConfigConstant;
import cc.rengu.oltp.service.common.constant.AppParamConstant;
import cc.rengu.oltp.utility.bean.PageInfo;
import cc.rengu.oltp.utility.bean.PageResult;
import cc.rengu.oltp.utility.util.DbsUtil;
import cc.rengu.oltp.utility.util.XmlConfigUtil;
import cc.rengu.oltp.utility.util.XmlTreeUtil;
import cc.rengu.utility.cache.UnifiedCache;
import cc.rengu.utility.log.RgLog;
import cc.rengu.utility.log.RgLogger;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 营销活动详情查询数据库操作接口实现
 *
 * @author Jinan Liu
 * @version 1.0.0
 * @date 2020/3/25 15:31
 */
public class McDetailInfoMapperImpl implements McDetailInfoMapper {

    private RgLogger rglog = RgLog.getLogger(this.getClass().getName());
    private String dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(AppParamConstant.DATABASE_CONF_NODE, AppConfigConstant.MOMP_POOL_NAME);

    /**
     * @param instId
     * @param mcNo
     * @return cc.rengu.igas.momp.common.entity.TMMcAgentProfitSharingInfo
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/26 00:06
     * @description 代理商营销活动详情查询数据库操作接口实现
     */
    @Override
    public TMMcAgentProfitSharingInfo selectAgentProfitSharingMcInfo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectAgentProfitSharingMcDetailInfo");

        // 按接口赋查询条件
        TMMcAgentProfitSharingInfo mcAgentProfitSharingInfo = new TMMcAgentProfitSharingInfo();
        mcAgentProfitSharingInfo.setInstId(instId);
        mcAgentProfitSharingInfo.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, mcAgentProfitSharingInfo, mcAgentProfitSharingInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取代理商营销活动信息失败!<{}>", instId, mcNo, iReturnCode);
            return null;
        }

        return mcAgentProfitSharingInfo;
    }

    /**
     * 卡券营销活动详情查询数据库操作接口实现
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/28 18:56
     */
    @Override
    public TMMcCouponInfo selectCouponMcDetailInfo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcInfoByPrimaryKey");

        // 按接口赋查询条件
        TMMcCouponInfo mcCouponInfo = new TMMcCouponInfo();
        mcCouponInfo.setInstId(instId);
        mcCouponInfo.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, mcCouponInfo, mcCouponInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取卡券营销活动信息失败!<{}>", instId, mcNo, iReturnCode);
            return null;
        }

        return mcCouponInfo;
    }

    /**
     * 商户手续费优惠营销活动详情查询数据库操作接口实现
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return cc.rengu.igas.momp.common.entity.TMMcMchntFeeDiscountInfo 商户手续费减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/28 18:56
     */
    @Override
    public TMMcMchntFeeDiscountInfo selectMchntFeeDiscountMcDetailInfo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMchntFeeDiscountMcDetailInfo");

        // 按接口赋查询条件
        TMMcMchntFeeDiscountInfo mcMchntFeeDiscountInfo = new TMMcMchntFeeDiscountInfo();
        mcMchntFeeDiscountInfo.setInstId(instId);
        mcMchntFeeDiscountInfo.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, mcMchntFeeDiscountInfo, mcMchntFeeDiscountInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取商户手续费优惠营销活动信息失败!<{}>", instId, mcNo, iReturnCode);
            return null;
        }

        return mcMchntFeeDiscountInfo;
    }

    /**
     * 减免营销活动详情查询数据库操作接口实现
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return cc.rengu.igas.momp.common.entity.TMMcMoneyOffInfo 减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/26 00:06
     */
    @Override
    public TMMcMoneyOffInfo selectMoneyOffMcDetailInfo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoneyOffMcDetailInfo");

        // 按接口赋查询条件
        TMMcMoneyOffInfo tmMcMoneyOffInfoIn = new TMMcMoneyOffInfo();
        tmMcMoneyOffInfoIn.setInstId(instId);
        tmMcMoneyOffInfoIn.setMcNo(mcNo);

        TMMcMoneyOffInfo tmMcMoneyOffInfoOut = new TMMcMoneyOffInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmMcMoneyOffInfoIn, tmMcMoneyOffInfoOut);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", instId, mcNo, iReturnCode);
            return null;
        }

        return tmMcMoneyOffInfoOut;
    }

    /**
     * 进行中的减免营销活动详情查询数据库操作接口实现
     *
     * @param instId   法人机构号
     * @param mcNo     营销活动编号
     * @param mcStatus 营销活动状态
     * @return cc.rengu.igas.momp.common.entity.TMMcMoneyOffInfo 减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/3/26 00:06
     */
    @Override
    public TMMcMoneyOffInfo selectMoMcDetailInfoByMcStatus(String instId, String mcNo, String mcStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoMcDetailInfoByMcStatus");

        // 按接口赋查询条件
        TMMcMoneyOffInfo tmMcMoneyOffInfoIn = new TMMcMoneyOffInfo();
        tmMcMoneyOffInfoIn.setInstId(instId);
        tmMcMoneyOffInfoIn.setMcNo(mcNo);
        tmMcMoneyOffInfoIn.setMcStatus(mcStatus);

        TMMcMoneyOffInfo tmMcMoneyOffInfoOut = new TMMcMoneyOffInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmMcMoneyOffInfoIn, tmMcMoneyOffInfoOut);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", instId, mcNo, iReturnCode);
            return null;
        }

        return tmMcMoneyOffInfoOut;
    }

    /**
     * 银行操作员查询卡券类营销活动基本信息表数据库操作接口定义
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 15:17
     */
    @Override
    public TMMcCouponInfo selectCouponMcDetailInfoByBankBasicRole(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcDetailInfoByBankBasicRole");

        TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, cpMcListInfoInObj, tmMcCouponInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取卡券类营销活动信息失败!<{}>", cpMcListInfoInObj.getInstId(), cpMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcCouponInfo;
    }

    /**
     * 银行操作员查询商户手续费优惠类营销活动基本信息表数据库操作接口定义
     *
     * @param mfdMcListInfoInObj 商户手续费优惠类营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcMchntFeeDiscountInfo 商户手续费减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 15:17
     */
    @Override
    public TMMcMchntFeeDiscountInfo selectMfdMcDetailInfoByBankBasicRole(MfdMcListInfoInObj mfdMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMfdMcDetailInfoByBankBasicRole");

        TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo = new TMMcMchntFeeDiscountInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, mfdMcListInfoInObj, tmMcMchntFeeDiscountInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取商户手续费优惠类营销活动信息失败!<{}>", mfdMcListInfoInObj.getInstId(), mfdMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcMchntFeeDiscountInfo;
    }

    /**
     * 银行操作员查询营销活动基本信息表数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcMoneyOffInfo 减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 15:19
     */
    @Override
    public TMMcMoneyOffInfo selectMoneyOffMcDetailInfoByBankBasicRole(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoneyOffMcDetailInfoByBankBasicRole");

        TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, moMcListInfoInObj, tmMcMoneyOffInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcMoneyOffInfo;
    }

    /**
     * 银行发布员查询卡券类营销活动基本信息表数据库操作接口定义
     *
     * @param cpMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:49
     */
    @Override
    public TMMcCouponInfo selectCouponMcDetailInfoByBankPublishRole(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcDetailInfoByBankPublishRole");

        TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, cpMcListInfoInObj, tmMcCouponInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取卡券类营销活动信息失败!<{}>", cpMcListInfoInObj.getInstId(), cpMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcCouponInfo;
    }

    /**
     * 银行发布员查询商户手续费优惠营销活动基本信息表数据库操作接口定义
     *
     * @param mfdMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcMchntFeeDiscountInfo 商户手续费减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:49
     */
    @Override
    public TMMcMchntFeeDiscountInfo selectMfdMcDetailInfoByBankPublishRole(MfdMcListInfoInObj mfdMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMfdMcDetailInfoByBankPublishRole");

        TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo = new TMMcMchntFeeDiscountInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, mfdMcListInfoInObj, tmMcMchntFeeDiscountInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取商户手续费优惠类营销活动信息失败!<{}>", mfdMcListInfoInObj.getInstId(), mfdMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcMchntFeeDiscountInfo;
    }

    /**
     * 银行发布员查询营销活动基本信息表数据库操作接口实现
     *
     * @param moMcListInfoInObj
     * @return cc.rengu.igas.momp.common.entity.TMMcMoneyOffInfo
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:50
     */
    @Override
    public TMMcMoneyOffInfo selectMoneyOffMcDetailInfoByBankPublishRole(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoneyOffMcDetailInfoByBankPublishRole");

        TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, moMcListInfoInObj, tmMcMoneyOffInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcMoneyOffInfo;
    }

    /**
     * 商户查询卡券类营销活动基本信息表数据库操作接口实现
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:12
     */
    @Override
    public TMMcCouponInfo selectCouponMcDetailInfoByMchnt(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcDetailInfoByMchnt");

        TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, cpMcListInfoInObj, tmMcCouponInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取卡券类营销活动信息失败!<{}>", cpMcListInfoInObj.getInstId(), cpMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcCouponInfo;
    }

    /**
     * 商户(带商圈编号)查询卡券类营销活动基本信息表数据库操作接口实现
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:12
     */
    @Override
    public TMMcCouponInfo selectCouponMcDetailInfoByMchntWithArea(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcDetailInfoByMchntWithArea");

        TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, cpMcListInfoInObj, tmMcCouponInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取卡券类营销活动信息失败!<{}>", cpMcListInfoInObj.getInstId(), cpMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcCouponInfo;
    }

    /**
     * 商户查询进行中的卡券类营销活动基本信息表数据库操作接口实现
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:12
     */
    @Override
    public TMMcCouponInfo selectAvailableCouponMcDetailInfoByMchnt(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectAvailableCouponMcDetailInfoByMchnt");

        TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, cpMcListInfoInObj, tmMcCouponInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取进行中的卡券类营销活动信息失败!<{}>", cpMcListInfoInObj.getInstId(), cpMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcCouponInfo;
    }

    /**
     * 商户(带商圈编号)查询进行中的卡券类营销活动基本信息表数据库操作接口实现
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:12
     */
    @Override
    public TMMcCouponInfo selectAvailableCouponMcDetailInfoByMchntWithArea(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectAvailableCouponMcDetailInfoByMchntWithArea");

        TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, cpMcListInfoInObj, tmMcCouponInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取进行中的卡券类营销活动信息失败!<{}>", cpMcListInfoInObj.getInstId(), cpMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcCouponInfo;
    }

    /**
     * 商户查询营销活动基本信息表数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcMoneyOffInfo 减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:12
     */
    @Override
    public TMMcMoneyOffInfo selectMoneyOffMcDetailInfoByMchnt(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoneyOffMcDetailInfoByMchnt");

        TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, moMcListInfoInObj, tmMcMoneyOffInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcMoneyOffInfo;
    }

    /**
     * 商户(带商圈编号)查询营销活动基本信息表数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcMoneyOffInfo 减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:12
     */
    @Override
    public TMMcMoneyOffInfo selectMoneyOffMcDetailInfoByMchntWithArea(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoneyOffMcDetailInfoByMchntWithArea");

        TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, moMcListInfoInObj, tmMcMoneyOffInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取减免类营销活动信息失败!<{}>", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcMoneyOffInfo;
    }

    /**
     * 通用营销活动详情查询数据库操作接口实现
     *
     * @param instId    法人机构号
     * @param mcNo      营销活动编号
     * @param tableName 数据库表名
     * @return java.lang.Object 应答对象
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/26 02:45
     */
    @Override
    public Object selectMcDetailInfo(String instId, String mcNo, String tableName) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);

        String sqlStr = null;
        Object objectOut = null;
        int iReturnCode;

        rglog.debug("INST_ID=<{}>, MC_NO=<{}>", instId, mcNo);

        switch (TableNameEnum.getByValue(tableName)) {
            case T_M_MC_APS_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectAgentProfitSharingMcDetailInfo");
                TMMcAgentProfitSharingInfo tmMcAgentProfitSharingInfo = new TMMcAgentProfitSharingInfo();
                objectOut = new TMMcAgentProfitSharingInfo();
                tmMcAgentProfitSharingInfo.setInstId(instId);
                tmMcAgentProfitSharingInfo.setMcNo(mcNo);
                iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmMcAgentProfitSharingInfo, objectOut);
                break;
            case T_M_MC_CCB_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCashierCashbackMcDetailInfo");
                TMMcCashierCashbackInfo tmMcCashierCashbackInfo = new TMMcCashierCashbackInfo();
                objectOut = new TMMcCashierCashbackInfo();
                tmMcCashierCashbackInfo.setInstId(instId);
                tmMcCashierCashbackInfo.setMcNo(mcNo);
                iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmMcCashierCashbackInfo, objectOut);
                break;
            case T_M_MC_CP_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcInfoByPrimaryKey");
                TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();
                objectOut = new TMMcCouponInfo();
                tmMcCouponInfo.setInstId(instId);
                tmMcCouponInfo.setMcNo(mcNo);
                iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmMcCouponInfo, objectOut);
                break;
            case T_M_MC_MFD_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMchntFeeDiscountMcDetailInfo");
                TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo = new TMMcMchntFeeDiscountInfo();
                objectOut = new TMMcMchntFeeDiscountInfo();
                tmMcMchntFeeDiscountInfo.setInstId(instId);
                tmMcMchntFeeDiscountInfo.setMcNo(mcNo);
                iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmMcMchntFeeDiscountInfo, objectOut);
                break;
            case T_M_MC_MO_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMoneyOffMcDetailInfo");
                TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();
                objectOut = new TMMcMoneyOffInfo();
                tmMcMoneyOffInfo.setInstId(instId);
                tmMcMoneyOffInfo.setMcNo(mcNo);
                iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmMcMoneyOffInfo, objectOut);
                break;
            default:
                rglog.error("不支持的营销活动类型! TABLE_NAME=<{}>", instId, mcNo, tableName);
                return null;
        }

        /* 数据库操作 */
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取<{}>数据失败!<{}>", instId, mcNo, TableNameEnum.getByValue(tableName).getTableNameDesc(), iReturnCode);
            return null;
        }

        return objectOut;
    }

    /**
     * 卡券类营销活动信息新增数据库操作接口实现
     *
     * @param tmMcCouponInfo 卡券类营销活动信息表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/21 10:29
     */
    @Override
    public int insertSingleCouponMcInfo(TMMcCouponInfo tmMcCouponInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "insertSingleCouponMcInfo");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCouponInfo, TMMcCouponInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("插入法人机构号<{}>营销活动编号<{}>的卡券类营销活动基本信息失败!<{}>", tmMcCouponInfo.getInstId(), tmMcCouponInfo.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 商户手续费优惠营销活动信息新增数据库操作接口实现
     *
     * @param tmMcMchntFeeDiscountInfo 减免类营销活动信息表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/21 10:29
     */
    @Override
    public int insertSingleMfdMcInfo(TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "insertSingleMfdMcInfo");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMchntFeeDiscountInfo, TMMcMchntFeeDiscountInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("插入法人机构号<{}>营销活动编号<{}>的商户手续费优惠类营销活动基本信息失败!<{}>", tmMcMchntFeeDiscountInfo.getInstId(), tmMcMchntFeeDiscountInfo.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 减免营销活动信息新增数据库操作接口实现
     *
     * @param mcMoneyOffInfo 减免类营销活动信息表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/1 21:50
     */
    @Override
    public int insertSingleMoneyOffMcInfo(TMMcMoneyOffInfo mcMoneyOffInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "insertSingleMoneyOffMcInfo");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, mcMoneyOffInfo, TMMcMoneyOffInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("插入法人机构号<{}>营销活动编号<{}>的减免类营销活动基本信息失败!<{}>", mcMoneyOffInfo.getInstId(), mcMoneyOffInfo.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 减免营销活动信息删除数据库操作接口实现
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/1 21:50
     */
    @Override
    public int deleteMoneyOffMcInfo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteMoneyOffMcInfo");

        TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();
        tmMcMoneyOffInfo.setInstId(instId);
        tmMcMoneyOffInfo.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMoneyOffInfo, TMMcMoneyOffInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("删除法人机构号<{}>营销活动编号<{}>的减免类营销活动基本信息失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用主键更新减免类营销活动审批状态数据库操作接口实现
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus 审批状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 22:19
     */
    @Override
    public int updateMoneyOffMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMoneyOffMcAuditStatusByPrimaryKey");

        TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();
        tmMcMoneyOffInfo.setInstId(instId);
        tmMcMoneyOffInfo.setMcNo(mcNo);
        tmMcMoneyOffInfo.setMcStatus(McStatusEnum.DRAFT.getMcStatusCode());
        tmMcMoneyOffInfo.setAuditStatus(auditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMoneyOffInfo, TMMcMoneyOffInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用主键更新减免类营销活动审批状态数据库操作接口定义
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus 审批状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 23:43
     */
    @Override
    public int updateMoneyOffMcAuditStatusByPrimaryKeyForTask(String instId, String mcNo, String auditStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMoneyOffMcAuditStatusByPrimaryKeyForTask");

        TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();
        tmMcMoneyOffInfo.setInstId(instId);
        tmMcMoneyOffInfo.setMcNo(mcNo);
        tmMcMoneyOffInfo.setMcStatus(McStatusEnum.DRAFT.getMcStatusCode());
        tmMcMoneyOffInfo.setAuditStatus(auditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMoneyOffInfo, TMMcMoneyOffInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 代理商营销活动信息新增数据库操作接口实现
     *
     * @param instId                   法人机构号
     * @param mcAgentProfitSharingInfo 代理商营销活动信息表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 23:43
     */
    @Override
    public int insertAgentProfitSharingMcInfo(String instId, TMMcAgentProfitSharingInfo mcAgentProfitSharingInfo) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "insertAgentProfitSharingMcInfo");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, mcAgentProfitSharingInfo, TMMcAgentProfitSharingInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("插入法人机构号<{}>营销活动编号<{}>的代理商分润类营销活动基本信息失败!<{}>", mcAgentProfitSharingInfo.getInstId(), mcAgentProfitSharingInfo.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 代理商营销活动信息删除数据库操作接口实现
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 22:54
     */
    @Override
    public int deleteAgentProfitSharingMcInfo(String instId, String mcNo) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteAgentProfitSharingMcInfo");

        TMMcAgentProfitSharingInfo tMMcAgentProfitSharingInfo = new TMMcAgentProfitSharingInfo();
        tMMcAgentProfitSharingInfo.setInstId(instId);
        tMMcAgentProfitSharingInfo.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tMMcAgentProfitSharingInfo, TMMcMoneyOffInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("删除法人机构号<{}>营销活动编号<{}>的代理商分润类营销活动基本信息失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用主键更新代理商类营销活动审批状态数据库操作接口实现
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus 审批状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 22:54
     */
    @Override
    public int updateAgentProfitSharingMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateAgentProfitSharingMcAuditStatusByPrimaryKey");

        TMMcAgentProfitSharingInfo tmMcAgentProfitSharingInfo = new TMMcAgentProfitSharingInfo();
        tmMcAgentProfitSharingInfo.setInstId(instId);
        tmMcAgentProfitSharingInfo.setMcNo(mcNo);
        tmMcAgentProfitSharingInfo.setMcStatus(McStatusEnum.DRAFT.getMcStatusCode());
        tmMcAgentProfitSharingInfo.setAuditStatus(auditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcAgentProfitSharingInfo, TMMcMoneyOffInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 收银员返现营销活动信息新增数据库操作接口实现
     *
     * @param mcCashierCashbackInfo 收银员返现类营销活动信息表
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 22:53
     */
    @Override
    public int insertCashierCashbackMcInfo(TMMcCashierCashbackInfo mcCashierCashbackInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "insertSingleCashierCashbackInfo");

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, mcCashierCashbackInfo, TMMcCashierCashbackInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("插入法人机构号<{}>营销活动编号<{}>的收银员返现类营销活动基本信息失败!<{}>", mcCashierCashbackInfo.getInstId(), mcCashierCashbackInfo.getMcNo(), iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 收银员返现营销活动信息删除数据库操作接口实现
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 22:54
     */
    @Override
    public int deleteCashierCashbackMcInfo(String instId, String mcNo) throws Exception {////
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteCashierCashbackMcInfo");

        TMMcCashierCashbackInfo tmMcCashierCashbackInfo = new TMMcCashierCashbackInfo();
        tmMcCashierCashbackInfo.setInstId(instId);
        tmMcCashierCashbackInfo.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCashierCashbackInfo, TMMcCashierCashbackInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("删除法人机构号<{}>营销活动编号<{}>的收银员返现类营销活动基本信息失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用主键更新收银员返现营销活动审批状态数据库操作接口实现
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus 审批状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 22:54
     */
    @Override
    public int updateCashierCashbackMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCashierCashbackMcAuditStatusByPrimaryKey");

        TMMcCashierCashbackInfo tmMcCashierCashbackInfo = new TMMcCashierCashbackInfo();
        tmMcCashierCashbackInfo.setInstId(instId);
        tmMcCashierCashbackInfo.setMcNo(mcNo);
        tmMcCashierCashbackInfo.setMcStatus(McStatusEnum.DRAFT.getMcStatusCode());
        tmMcCashierCashbackInfo.setAuditStatus(auditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCashierCashbackInfo, TMMcCashierCashbackInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    @Override
    public int updateCashierCashbackMcAuditStatusByPrimaryKeyForTask(String instId, String mcNo, String auditStatus) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCashierCashbackMcAuditStatusByPrimaryKeyForTask");

        TMMcCashierCashbackInfo tmMcCashierCashbackInfo = new TMMcCashierCashbackInfo();
        tmMcCashierCashbackInfo.setInstId(instId);
        tmMcCashierCashbackInfo.setMcNo(mcNo);
        tmMcCashierCashbackInfo.setMcStatus(McStatusEnum.DRAFT.getMcStatusCode());
        tmMcCashierCashbackInfo.setAuditStatus(auditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCashierCashbackInfo, TMMcCashierCashbackInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 卡券类营销活动信息删除数据库操作接口实现
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 23:43
     */
    @Override
    public int deleteCpMcInfo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteCpMcInfo");

        TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();
        tmMcCouponInfo.setInstId(instId);
        tmMcCouponInfo.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCouponInfo, TMMcCouponInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("删除法人机构号<{}>营销活动编号<{}>的卡券类营销活动基本信息失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用主键查询卡券类营销活动信息数据库操作接口实现
     *
     * @param tmMcCouponInfo 卡券类营销活动信息表
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 22:54
     */
    @Override
    public TMMcCouponInfo selectCouponMcInfoByPrimaryKey(TMMcCouponInfo tmMcCouponInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcInfoByPrimaryKey");

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, tmMcCouponInfo, tmMcCouponInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("法人机构号<{}>获取卡券营销活动<{}>信息失败! RETURN_CODE=<{}>", tmMcCouponInfo.getInstId(), tmMcCouponInfo.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcCouponInfo;
    }

    /**
     * 使用主键更新卡券类营销活动审批状态数据库操作接口实现
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus 审批状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 23:42
     */
    @Override
    public int updateCouponMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCouponMcAuditStatusByPrimaryKey");

        TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();
        tmMcCouponInfo.setInstId(instId);
        tmMcCouponInfo.setMcNo(mcNo);
        tmMcCouponInfo.setMcStatus(McStatusEnum.DRAFT.getMcStatusCode());
        tmMcCouponInfo.setAuditStatus(auditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCouponInfo, TMMcCouponInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用主键更新卡券类营销活动审批状态数据库操作接口实现
     * 定时任务使用
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus 审批状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 23:42
     */
    @Override
    public int updateCouponMcAuditStatusByPrimaryKeyForTask(String instId, String mcNo, String auditStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCouponMcAuditStatusByPrimaryKeyForTask");

        TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();
        tmMcCouponInfo.setInstId(instId);
        tmMcCouponInfo.setMcNo(mcNo);
        tmMcCouponInfo.setMcStatus(McStatusEnum.DRAFT.getMcStatusCode());
        tmMcCouponInfo.setAuditStatus(auditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCouponInfo, TMMcCouponInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 商户手续费优惠营销活动信息删除数据库操作接口实现
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return int 返回码
     * @throws Exception
     * @author Jinan Liu
     * @date 2020/4/6 23:43
     */
    @Override
    public int deleteMfdMcInfo(String instId, String mcNo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteMfdMcInfo");

        TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo = new TMMcMchntFeeDiscountInfo();
        tmMcMchntFeeDiscountInfo.setInstId(instId);
        tmMcMchntFeeDiscountInfo.setMcNo(mcNo);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMchntFeeDiscountInfo, TMMcMchntFeeDiscountInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
            rglog.error("删除法人机构号<{}>营销活动编号<{}>的商户手续费优惠类营销活动基本信息失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用主键更新商户手续费优惠营销活动审批状态数据库操作接口实现
     *
     * @param instId      法人机构号
     * @param mcNo        营销活动编号
     * @param auditStatus 审批状态
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/6 23:42
     */
    @Override
    public int updateMfdMcAuditStatusByPrimaryKey(String instId, String mcNo, String auditStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMfdMcAuditStatusByPrimaryKey");

        TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo = new TMMcMchntFeeDiscountInfo();
        tmMcMchntFeeDiscountInfo.setInstId(instId);
        tmMcMchntFeeDiscountInfo.setMcNo(mcNo);
        tmMcMchntFeeDiscountInfo.setMcStatus(McStatusEnum.DRAFT.getMcStatusCode());
        tmMcMchntFeeDiscountInfo.setAuditStatus(auditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMchntFeeDiscountInfo, TMMcMchntFeeDiscountInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    @Override
    public int updateMfdMcAuditStatusByPrimaryKeyForTask(String instId, String mcNo, String auditStatus) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMfdMcAuditStatusByPrimaryKeyForTask");

        TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo = new TMMcMchntFeeDiscountInfo();
        tmMcMchntFeeDiscountInfo.setInstId(instId);
        tmMcMchntFeeDiscountInfo.setMcNo(mcNo);
        tmMcMchntFeeDiscountInfo.setMcStatus(McStatusEnum.DRAFT.getMcStatusCode());
        tmMcMchntFeeDiscountInfo.setAuditStatus(auditStatus);

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMchntFeeDiscountInfo, TMMcMchntFeeDiscountInfo.class);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新草稿状态法人机构号<{}>营销活动编号<{}>的营销活动信息审批状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用表名、营销活动编号和营销活动审批状态更新营销活动审批状态数据库操作接口实现
     *
     * @param tableName      数据库表名
     * @param instId         法人机构号
     * @param mcNo           营销活动编号
     * @param newAuditStatus 新审批状态
     * @param oldAuditStatus 就审批状态
     * @param oprId          操作员ID
     * @param timeStamp      时间戳
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/7 02:02
     */
    @Override
    public int updateMcAuditStatusByMcNoAndAuditStatusAndTableName(String tableName, String instId, String mcNo, String newAuditStatus, String oldAuditStatus, String oprId, String timeStamp, String auditReason) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        int iReturnCode;
        String sqlStr;
        Object object = new Object();

        switch (TableNameEnum.getByValue(tableName)) {
            case T_M_MC_APS_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateApsMcAuditStatusByMcNoAndAuditStatusAndTableName");

                TMMcAgentProfitSharingInfo tmMcAgentProfitSharingInfo = new TMMcAgentProfitSharingInfo();
                tmMcAgentProfitSharingInfo.setInstId(instId);
                tmMcAgentProfitSharingInfo.setMcNo(mcNo);
                tmMcAgentProfitSharingInfo.setAuditStatus(newAuditStatus);
                tmMcAgentProfitSharingInfo.setRemark1(oldAuditStatus);
                tmMcAgentProfitSharingInfo.setLastOprId(oprId);
                tmMcAgentProfitSharingInfo.setUpdateTime(timeStamp);
                tmMcAgentProfitSharingInfo.setAuditRefuseReason(auditReason);

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcAgentProfitSharingInfo, TMMcAgentProfitSharingInfo.class);
                break;
            case T_M_MC_CCB_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCcbMcAuditStatusByMcNoAndAuditStatusAndTableName");

                TMMcCashierCashbackInfo tmMcCashierCashbackInfo = new TMMcCashierCashbackInfo();
                tmMcCashierCashbackInfo.setInstId(instId);
                tmMcCashierCashbackInfo.setMcNo(mcNo);
                tmMcCashierCashbackInfo.setAuditStatus(newAuditStatus);
                tmMcCashierCashbackInfo.setRemark1(oldAuditStatus);
                tmMcCashierCashbackInfo.setLastOprId(oprId);
                tmMcCashierCashbackInfo.setUpdateTime(timeStamp);
                tmMcCashierCashbackInfo.setAuditRefuseReason(auditReason);

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCashierCashbackInfo, TMMcCashierCashbackInfo.class);
                break;
            case T_M_MC_CP_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCpMcAuditStatusByMcNoAndAuditStatusAndTableName");

                TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();
                tmMcCouponInfo.setInstId(instId);
                tmMcCouponInfo.setMcNo(mcNo);
                tmMcCouponInfo.setAuditStatus(newAuditStatus);
                tmMcCouponInfo.setRemark1(oldAuditStatus);
                tmMcCouponInfo.setLastOprId(oprId);
                tmMcCouponInfo.setUpdateTime(timeStamp);
                tmMcCouponInfo.setAuditRefuseReason(auditReason);

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCouponInfo, TMMcCouponInfo.class);
                break;
            case T_M_MC_MFD_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMfdMcAuditStatusByMcNoAndAuditStatusAndTableName");

                TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo = new TMMcMchntFeeDiscountInfo();
                tmMcMchntFeeDiscountInfo.setInstId(instId);
                tmMcMchntFeeDiscountInfo.setMcNo(mcNo);
                tmMcMchntFeeDiscountInfo.setAuditStatus(newAuditStatus);
                tmMcMchntFeeDiscountInfo.setRemark1(oldAuditStatus);
                tmMcMchntFeeDiscountInfo.setLastOprId(oprId);
                tmMcMchntFeeDiscountInfo.setUpdateTime(timeStamp);
                tmMcMchntFeeDiscountInfo.setAuditRefuseReason(auditReason);

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMchntFeeDiscountInfo, TMMcMchntFeeDiscountInfo.class);
                break;
            case T_M_MC_MO_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMoMcAuditStatusByMcNoAndAuditStatusAndTableName");

                TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();
                tmMcMoneyOffInfo.setInstId(instId);
                tmMcMoneyOffInfo.setMcNo(mcNo);
                tmMcMoneyOffInfo.setAuditStatus(newAuditStatus);
                tmMcMoneyOffInfo.setRemark1(oldAuditStatus);
                tmMcMoneyOffInfo.setLastOprId(oprId);
                tmMcMoneyOffInfo.setUpdateTime(timeStamp);
                tmMcMoneyOffInfo.setAuditRefuseReason(auditReason);

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMoneyOffInfo, TMMcMoneyOffInfo.class);
                break;
            default:
                rglog.error("不支持的数据库表操作!TABLE_NAME=<{}>", tableName);
                return CommonConstant.PROCESS_FAILED;
        }

        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动发布拒绝相关数据失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 发布成功更新营销活动状态数据数据库操作接口定义
     * 各营销活动通用
     *
     * @param object    数据库操作对象
     * @param tableName 数据库表名
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/26 20:53
     */
    @Override
    public int updateMcStatusForPublishing(Object object, String tableName) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {

            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr;
        String instId;
        String mcNo;

        switch (TableNameEnum.getByValue(tableName)) {
            case T_M_MC_APS_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateApsMcStatusForPublishing");
                instId = ((TMMcAgentProfitSharingInfo) object).getInstId();
                mcNo = ((TMMcAgentProfitSharingInfo) object).getMcNo();
                break;
            case T_M_MC_CCB_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCcbMcStatusForPublishing");
                instId = ((TMMcCashierCashbackInfo) object).getInstId();
                mcNo = ((TMMcCashierCashbackInfo) object).getMcNo();
                break;
            case T_M_MC_CP_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCpMcStatusForPublishing");
                instId = ((TMMcCouponInfo) object).getInstId();
                mcNo = ((TMMcCouponInfo) object).getMcNo();
                break;
            case T_M_MC_MFD_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMfdMcStatusForPublishing");
                instId = ((TMMcMchntFeeDiscountInfo) object).getInstId();
                mcNo = ((TMMcMchntFeeDiscountInfo) object).getMcNo();
                break;
            case T_M_MC_MO_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMoMcStatusForPublishing");
                instId = ((TMMcMoneyOffInfo) object).getInstId();
                mcNo = ((TMMcMoneyOffInfo) object).getMcNo();
                break;
            default:
                rglog.error("不支持的数据库表操作!TABLE_NAME=<{}>", tableName);
                return CommonConstant.PROCESS_FAILED;
        }

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, object, object.getClass());
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动发布成功状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 活动中中添加商户流程发布成功更新减免类营销活动预算数据数据库操作接口实现
     * 各类型营销活动通用
     *
     * @param object 输入对象
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/26 04:01
     */
    @Override
    public int updateMcBudgetForPublishing(Object object) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);

        String sqlStr;
        String instId;
        String mcNo;
        Class className;

        if (object instanceof TMMcCouponInfo) {

            className = TMMcCouponInfo.class;
            instId = ((TMMcCouponInfo) object).getInstId();
            mcNo = ((TMMcCouponInfo) object).getMcNo();
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCpMcBudgetForPublishing");
        } else if (object instanceof TMMcMchntFeeDiscountInfo) {

            className = TMMcMchntFeeDiscountInfo.class;
            instId = ((TMMcMchntFeeDiscountInfo) object).getInstId();
            mcNo = ((TMMcMchntFeeDiscountInfo) object).getMcNo();
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMfdMcBudgetForPublishing");
        } else if (object instanceof TMMcMoneyOffInfo) {

            className = TMMcMoneyOffInfo.class;
            instId = ((TMMcMoneyOffInfo) object).getInstId();
            mcNo = ((TMMcMoneyOffInfo) object).getMcNo();
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMoMcBudgetForPublishing");
        } else {
            rglog.error("不支持的实体类! OBJECT.CLASS=<{}>", object.getClass().getName());
            return CommonConstant.PROCESS_FAILED;
        }

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, object, className);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动预算相关数据失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 发布拒绝更新营销活动审批状态和发布拒绝原因数据库操作接口实现
     * 各类型营销活动通用
     *
     * @param object    数据库操作实体类
     * @param tableName 数据库表名
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/26 21:13
     */
    @Override
    public int updateMcAuditStatusForPublishRefusal(Object object, String tableName) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr;
        String instId;
        String mcNo;
        int iReturnCode;

        switch (TableNameEnum.getByValue(tableName)) {
            case T_M_MC_APS_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateApsMcAuditStatusForPublishRefusal");

                TMMcAgentProfitSharingInfo tmMcAgentProfitSharingInfo = (TMMcAgentProfitSharingInfo) object;
                instId = tmMcAgentProfitSharingInfo.getInstId();
                mcNo = tmMcAgentProfitSharingInfo.getMcNo();

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcAgentProfitSharingInfo, TMMcAgentProfitSharingInfo.class);
                break;
            case T_M_MC_CCB_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCcbMcAuditStatusForPublishRefusal");

                TMMcCashierCashbackInfo tmMcCashierCashbackInfo = (TMMcCashierCashbackInfo) object;
                instId = tmMcCashierCashbackInfo.getInstId();
                mcNo = tmMcCashierCashbackInfo.getMcNo();

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCashierCashbackInfo, TMMcCashierCashbackInfo.class);
                break;
            case T_M_MC_CP_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCpMcAuditStatusForPublishRefusal");

                TMMcCouponInfo tmMcCouponInfo = (TMMcCouponInfo) object;
                instId = tmMcCouponInfo.getInstId();
                mcNo = tmMcCouponInfo.getMcNo();

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCouponInfo, TMMcCouponInfo.class);
                break;
            case T_M_MC_MFD_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMfdMcAuditStatusForPublishRefusal");

                TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo = (TMMcMchntFeeDiscountInfo) object;
                instId = tmMcMchntFeeDiscountInfo.getInstId();
                mcNo = tmMcMchntFeeDiscountInfo.getMcNo();

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMchntFeeDiscountInfo, TMMcMchntFeeDiscountInfo.class);
                break;
            case T_M_MC_MO_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMoMcAuditStatusForPublishRefusal");

                TMMcMoneyOffInfo tmMcMoneyOffInfo = (TMMcMoneyOffInfo) object;
                instId = tmMcMoneyOffInfo.getInstId();
                mcNo = tmMcMoneyOffInfo.getMcNo();

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMoneyOffInfo, TMMcMoneyOffInfo.class);
                break;
            default:
                rglog.error("不支持的数据库表操作!TABLE_NAME=<{}>", tableName);
                return CommonConstant.PROCESS_FAILED;
        }

        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动发布拒绝相关数据失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 启用已暂停营销活动更新营销活动状态数据库操作接口定义
     * 目前支持减免类\卡券类和收银员返现类营销活动
     * 启用已暂停\暂停进行中\强制终止进行中营销活动时使用
     *
     * @param object    数据库实体类
     * @param tableName 数据库表名
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/26 21:27
     */
    @Override
    public int updatePausedMcMcStatusForEnabling(Object object, String tableName) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr;
        String instId;
        String mcNo;

        switch (TableNameEnum.getByValue(tableName)) {

            case T_M_MC_CCB_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updatePausedCcbMcMcStatusForEnabling");
                instId = ((TMMcCashierCashbackInfo) object).getInstId();
                mcNo = ((TMMcCashierCashbackInfo) object).getMcNo();
                break;
            case T_M_MC_CP_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updatePausedCpMcMcStatusForEnabling");
                instId = ((TMMcCouponInfo) object).getInstId();
                mcNo = ((TMMcCouponInfo) object).getMcNo();
                break;
            case T_M_MC_MO_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updatePausedMoMcMcStatusForEnabling");
                instId = ((TMMcMoneyOffInfo) object).getInstId();
                mcNo = ((TMMcMoneyOffInfo) object).getMcNo();
                break;
            case T_M_MC_MFD_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updatePausedMfdMcMcStatusForEnabling");
                instId = ((TMMcMchntFeeDiscountInfo) object).getInstId();
                mcNo = ((TMMcMchntFeeDiscountInfo) object).getMcNo();
                break;
            case T_M_MC_APS_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updatePausedApsMcMcStatusForEnabling");
                instId = ((TMMcAgentProfitSharingInfo) object).getInstId();
                mcNo = ((TMMcAgentProfitSharingInfo) object).getMcNo();
                break;
            default:
                rglog.error("不支持的数据库表操作!TABLE_NAME=<{}>", tableName);
                return CommonConstant.PROCESS_FAILED;
        }

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, object, object.getClass());
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("启用已暂停的法人机构号<{}>营销活动编号<{}>的营销活动更新正式表数据失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用用户白名单查询用户所在卡券营销活动基本信息数据库操作接口定义
     * 分页查询
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @param pageInfo          数据库操作分页实体类
     * @return cc.rengu.oltp.utility.bean.PageResult 查询结果列表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/6/8 11:17
     */
    @Override
    public PageResult selectCouponMcInfoUsingUserWhiteList(CpMcListInfoInObj cpMcListInfoInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcInfoUsingUserWhiteList");

        return dbsUtil.dbsFetchPageListData(sqlStr, cpMcListInfoInObj, TMMcCouponInfo.class, pageInfo);
    }

    /**
     * 查询未使用卡券白名单的卡券营销活动基本信息数据库操作接口实现
     * 分页查询
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @param pageInfo          数据库操作分页实体类
     * @return cc.rengu.oltp.utility.bean.PageResult 查询结果列表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/6/8 11:17
     */
    @Override
    public PageResult selectCouponMcInfoWithoutUserWhiteList(CpMcListInfoInObj cpMcListInfoInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCouponMcInfoWithoutUserWhiteList");

        return dbsUtil.dbsFetchPageListData(sqlStr, cpMcListInfoInObj, TMMcCouponInfo.class, pageInfo);
    }


    /**
     * 银行录入岗查询营销活动基本信息表数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcAgentProfitSharingInfo 代理商营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:50
     */
    @Override
    public TMMcAgentProfitSharingInfo selectApsInfoDetailInfoByBankBasicRole(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectApsInfoDetailInfoByBankBasicRole");

        TMMcAgentProfitSharingInfo mcAgentProfitSharingInfo = new TMMcAgentProfitSharingInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, moMcListInfoInObj, mcAgentProfitSharingInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取代理商分润类营销活动信息失败!<{}>", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return mcAgentProfitSharingInfo;
    }

    /**
     * 查询未使用卡券白名单的测试中卡券营销活动基本信息数据库操作接口实现
     * 分页查询
     *
     * @param cpMcListInfoInObj 卡券类营销活动列表查询使用实体类入参
     * @param pageInfo          数据库操作分页实体类
     * @return cc.rengu.oltp.utility.bean.PageResult 查询结果列表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/6/8 11:17
     */
    @Override
    public PageResult selectTestCouponMcInfoWithoutUserWhiteList(CpMcListInfoInObj cpMcListInfoInObj, PageInfo pageInfo) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectTestCouponMcInfoWithoutUserWhiteList");

        return dbsUtil.dbsFetchPageListData(sqlStr, cpMcListInfoInObj, TMMcCouponInfo.class, pageInfo);
    }

    /**
     * 银行发布岗查询营销活动基本信息表数据库操作接口实现
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcAgentProfitSharingInfo 代理商营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:50
     */
    @Override
    public TMMcAgentProfitSharingInfo selectApsInfoDetailInfoByBankPublishRole(MoMcListInfoInObj moMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectApsInfoDetailInfoByBankPublishRole");

        TMMcAgentProfitSharingInfo mcAgentProfitSharingInfo = new TMMcAgentProfitSharingInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, moMcListInfoInObj, mcAgentProfitSharingInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取代理商分润类营销活动信息失败!<{}>", moMcListInfoInObj.getInstId(), moMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return mcAgentProfitSharingInfo;
    }

    /**
     * 银行操作员查询收银员返现营销活动基本信息表数据库操作接口定义
     *
     * @param ccbMcListInfoInObj 商户手续费优惠类营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcMchntFeeDiscountInfo 商户手续费减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 15:17
     */
    @Override
    public TMMcCashierCashbackInfo selectCashierCashDetailInfoByBankBasicRole(CcbMcListInfoInObj ccbMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectCashierCashDetailInfoByBankBasicRole");

        TMMcCashierCashbackInfo tmMcCashierCashbackInfo = new TMMcCashierCashbackInfo();

        int iReturnCode = dbsUtil.dbsExecuteSql(sqlStr, ccbMcListInfoInObj, tmMcCashierCashbackInfo);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("根据查询条件法人机构号<{}>营销活动编号<{}>获取收银员返现活动信息失败!<{}>", ccbMcListInfoInObj.getInstId(), ccbMcListInfoInObj.getMcNo(), iReturnCode);
            return null;
        }

        return tmMcCashierCashbackInfo;
    }

    /**
     * 使用表名、营销活动编号和营销活动各状态更新营销活动各状态数据库操作接口实现
     *
     * @param tableName 数据库表名
     * @param instId    法人机构号
     * @param mcNo      营销活动编号
     * @return int 返回码
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/7 02:02
     */
    @Override
    public int updateMcAllStatusByMcNoAndOriStatusAndTableName(String tableName, String instId, String mcNo, String oldMcStatus, String newMcStatus, String oldAuditStatus, String newAuditStatus) throws Exception {
        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        int iReturnCode;
        String sqlStr;

        switch (TableNameEnum.getByValue(tableName)) {
            case T_M_MC_CP_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateCpMcAllStatus");
                TMMcCouponInfo tmMcCouponInfo = new TMMcCouponInfo();
                tmMcCouponInfo.setInstId(instId);
                tmMcCouponInfo.setMcNo(mcNo);
                tmMcCouponInfo.setMcStatus(oldMcStatus);
                tmMcCouponInfo.setAuditStatus(oldAuditStatus);
                tmMcCouponInfo.setRemark1(newMcStatus);
                tmMcCouponInfo.setRemark2(newAuditStatus);

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcCouponInfo, TMMcCouponInfo.class);
                break;
            case T_M_MC_MO_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateMoMcAllStatus");
                TMMcMoneyOffInfo tmMcMoneyOffInfo = new TMMcMoneyOffInfo();
                tmMcMoneyOffInfo.setInstId(instId);
                tmMcMoneyOffInfo.setMcNo(mcNo);
                tmMcMoneyOffInfo.setMcStatus(oldMcStatus);
                tmMcMoneyOffInfo.setAuditStatus(oldAuditStatus);
                tmMcMoneyOffInfo.setRemark1(newMcStatus);
                tmMcMoneyOffInfo.setRemark2(newAuditStatus);

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMoneyOffInfo, TMMcMoneyOffInfo.class);
                break;
            case T_M_MC_MFD_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateMfdMcAllStatus");
                TMMcMchntFeeDiscountInfo tmMcMchntFeeDiscountInfo = new TMMcMchntFeeDiscountInfo();
                tmMcMchntFeeDiscountInfo.setInstId(instId);
                tmMcMchntFeeDiscountInfo.setMcNo(mcNo);
                tmMcMchntFeeDiscountInfo.setMcStatus(oldMcStatus);
                tmMcMchntFeeDiscountInfo.setAuditStatus(oldAuditStatus);
                tmMcMchntFeeDiscountInfo.setRemark1(newMcStatus);
                tmMcMchntFeeDiscountInfo.setRemark2(newAuditStatus);

                iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMchntFeeDiscountInfo, TMMcMchntFeeDiscountInfo.class);
                break;
            default:
                rglog.error("不支持的数据库表操作!TABLE_NAME=<{}>", tableName);
                return CommonConstant.PROCESS_FAILED;
        }

        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动发布拒绝相关数据失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 使用表名、营销活动编号和营销活动审批状态更新营销活动审批状态及拒绝原因数据库操作接口实现
     *
     * @param tableName 数据库表名
     * @return int 返回码
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/7/4
     */
    @Override
    public int updateMcInfoByMcNoAndAuditStatusAndTableName(Object object, String tableName) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {

            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr;
        String instId;
        String mcNo;

        switch (TableNameEnum.getByValue(tableName)) {
            case T_M_MC_APS_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateApsMcInfo");
                instId = ((TMMcAgentProfitSharingInfo) object).getInstId();
                mcNo = ((TMMcAgentProfitSharingInfo) object).getMcNo();
                break;
            case T_M_MC_CCB_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateCcbMcInfo");
                instId = ((TMMcCashierCashbackInfo) object).getInstId();
                mcNo = ((TMMcCashierCashbackInfo) object).getMcNo();
                break;
            case T_M_MC_CP_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateCpMcInfo");
                instId = ((TMMcCouponInfo) object).getInstId();
                mcNo = ((TMMcCouponInfo) object).getMcNo();
                break;
            case T_M_MC_MFD_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateMfdMcInfo");
                instId = ((TMMcMchntFeeDiscountInfo) object).getInstId();
                mcNo = ((TMMcMchntFeeDiscountInfo) object).getMcNo();
                break;
            case T_M_MC_MO_INFO:
                sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompUpdateMoMcInfo");
                instId = ((TMMcMoneyOffInfo) object).getInstId();
                mcNo = ((TMMcMoneyOffInfo) object).getMcNo();
                break;
            default:
                rglog.error("不支持的数据库表操作!TABLE_NAME=<{}>", tableName);
                return CommonConstant.PROCESS_FAILED;
        }

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, object, object.getClass());
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动发布成功状态失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 批量删除营销活动商户信息
     *
     * @param tmPlatBizTmpList 临时表数据list
     * @return int 返回码
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/4/1 21:50
     */
    @Override
    public int deleteByinstidmcNomchntNo(List<TMPlatBizTmp> tmPlatBizTmpList) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "deleteByinstidmcNomchntNo");

        for (TMPlatBizTmp tmPlatBizTmp : tmPlatBizTmpList) {
            TMMcMchntInfo tmMcMchntInfo = new TMMcMchntInfo();
            tmMcMchntInfo.setInstId(tmPlatBizTmp.getInstId());
            tmMcMchntInfo.setMchntNo(tmPlatBizTmp.getMchntNo());
            tmMcMchntInfo.setMcNo(tmPlatBizTmp.getMcNo());
            int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, tmMcMchntInfo, TMMcMchntInfo.class);
            if (Database.DBS_SUCCESS != iReturnCode && Database.DBS_NOT_FOUND != iReturnCode) {
                rglog.error("删除法人机构号<{}>营销活动编号<{}>的减免类营销活动基本信息失败!<{}>", tmPlatBizTmp.getInstId(), tmPlatBizTmp.getMcNo(), iReturnCode);
                return iReturnCode;
            }
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 查询指定机构支持新增商户的商户手续费优惠活动信息数据库操作实现
     *
     * @param mfdMcListInfoInObj 商户手续费优惠类营销活动列表查询使用实体类入参
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcMchntFeeDiscountInfo> 商户手续费减免类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/7/7 17:18
     */
    @Override
    public List<TMMcMchntFeeDiscountInfo> selectMfdMcDetailInfoForComboPayment(MfdMcListInfoInObj mfdMcListInfoInObj) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectMfdMcDetailInfoForComboPayment");

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, mfdMcListInfoInObj, TMMcMchntFeeDiscountInfo.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("根据查询条件法人机构号<{}>机构编号<{}>获取商户手续费优惠类营销活动信息失败!", mfdMcListInfoInObj.getInstId(), mfdMcListInfoInObj.getOrgId());
            return null;
        }

        return objectList.stream().map(item -> (TMMcMchntFeeDiscountInfo) (item)).collect(Collectors.toList());
    }

    /**
     * 活动中中添加商户流程发布成功更新减免类营销活动预算数据数据库操作接口实现
     * 各类型营销活动通用
     *
     * @param object 输入对象
     * @return int 返回码
     * @throws Exception 异常信息
     * @author JL PANG
     * @date 2020/5/26 04:01
     */
    @Override
    public int updataMcStatusForPublish(Object object) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);

        String sqlStr;
        String instId;
        String mcNo;
        Class className;

        if (object instanceof TMMcCouponInfo) {

            className = TMMcCouponInfo.class;
            instId = ((TMMcCouponInfo) object).getInstId();
            mcNo = ((TMMcCouponInfo) object).getMcNo();
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateCpMcAllStatusByMcNoAndAuditStatusAndTableName");
        } else if (object instanceof TMMcMchntFeeDiscountInfo) {

            className = TMMcMchntFeeDiscountInfo.class;
            instId = ((TMMcMchntFeeDiscountInfo) object).getInstId();
            mcNo = ((TMMcMchntFeeDiscountInfo) object).getMcNo();
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMfdMcAllStatusByMcNoAndAuditStatusAndTableName");
        } else if (object instanceof TMMcMoneyOffInfo) {

            className = TMMcMoneyOffInfo.class;
            instId = ((TMMcMoneyOffInfo) object).getInstId();
            mcNo = ((TMMcMoneyOffInfo) object).getMcNo();
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "updateMoMcAllStatusByMcNoAndAuditStatusAndTableName");
        } else {
            rglog.error("不支持的实体类! OBJECT.CLASS=<{}>", object.getClass().getName());
            return CommonConstant.PROCESS_FAILED;
        }

        int iReturnCode = dbsUtil.dbsExecuteTransactionSql(sqlStr, object, className);
        if (Database.DBS_SUCCESS != iReturnCode) {
            rglog.error("更新法人机构号<{}>营销活动编号<{}>的营销活动预算相关数据失败!<{}>", instId, mcNo, iReturnCode);
            return iReturnCode;
        }

        return Database.DBS_SUCCESS;
    }

    /**
     * 查询指定机构指定代理商的代理商分润活动
     *
     * @param agentNo 代理商编号
     * @param instId  法人机构号
     * @return cc.rengu.igas.momp.common.entity.TMMcMchntFeeDiscountInfo 商户手续费减免类营销活动信息表
     * @throws Exception 异常信息
     * @author JL PANG
     * @date 2020/7/7 17:18
     */
    @Override
    public List<TMMcAgentProfitSharingInfo> selectApsMcInfoList(String instId, String agentNo, String nowDate) throws Exception {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        TMMcAgentProfitSharingInfo tmMcAgentProfitSharingInfo = new TMMcAgentProfitSharingInfo();
        tmMcAgentProfitSharingInfo.setInstId(instId);
        tmMcAgentProfitSharingInfo.setAgentMchntNo(agentNo);
        tmMcAgentProfitSharingInfo.setMcStartDate(nowDate);
        tmMcAgentProfitSharingInfo.setMcEndDate(nowDate);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "selectApsMcInfoList");

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, tmMcAgentProfitSharingInfo, TMMcAgentProfitSharingInfo.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("根据查询条件法人机构号<{}>代理商编号<{}>获取代理商分润营销活动列表失败!", tmMcAgentProfitSharingInfo.getInstId(), tmMcAgentProfitSharingInfo.getAgentMchntNo());
            return null;
        }

        return objectList.stream().map(item -> (TMMcAgentProfitSharingInfo) (item)).collect(Collectors.toList());
    }
}

